﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Collections;
using System.Windows.Shapes;
using System.ComponentModel;

namespace MidwayBattle
{


    class CustomDefines
    {


        public const double SQUARE_STROKE_THICKNESS = 0.5;
        public static Brush SQUARE_STROKE_BRUSH = Brushes.White;

         public const int NBSQUARESX = 15;
         public const int NBSQUARESY = 15;
         public const int PLAYERS_AMOUNT = 2;

         public const int MAXTURNS = NBSQUARESX * NBSQUARESY;

         public const int ORIENT_TOBOTTOM = 0;
         public const int ORIENT_TOLEFT = 1;
         public const int ORIENT_TOTOP = 2;
         public const int ORIENT_TORIGHT = 3;

         public const int ORIENT_AMOUNT = 4;

         public ArrayList ORIENT_TAB { get; set; } 

        
         public const int TRAP_NOTRAP = 0;
         public const int TRAP_MINE = 1;
        
         public const int MINES_AMOUNT = 3;

         public const int WHEEL_HOUR = 0;
         public const int WHEEL_ANTIHOUR = 1;

         public const int SHOTSTATE_RANDOM  =	0;
         public const int SHOTSTATE_FIRING = 1;

         public const int SHIP_CARRIER = 0;
         public const int SHIP_CARRIER_AMOUNT = 1;
         public const int SHIP_CARRIER_SIZE = 5;
         public SolidColorBrush SHIP_CARRIER_COLOR = Brushes.Red;
         public const String SHIP_CARRIER_NAME = "Carrier";

         public const int SHIP_BATTLESHIP = 1;
         public const int SHIP_BATTLESHIP_AMOUNT = 1;
         public const int SHIP_BATTLESHIP_SIZE = 4;
         public SolidColorBrush SHIP_BATTLESHIP_COLOR = Brushes.Yellow;
         public const String SHIP_BATTLESHIP_NAME = "Battleship";
        
         public const int SHIP_CRUISER = 2;
         public const int SHIP_CRUISER_AMOUNT = 1;
         public const int SHIP_CRUISER_SIZE = 3;
         public SolidColorBrush SHIP_CRUISER_COLOR = Brushes.White;
         public const String SHIP_CRUISER_NAME = "Cruiser";
        
         public const int SHIP_DESTROYER = 3;
         public const int SHIP_DESTROYER_AMOUNT = 2;
         public const int SHIP_DESTROYER_SIZE = 2;
         public SolidColorBrush SHIP_DESTROYER_COLOR = Brushes.DarkGreen;
         public const String SHIP_DESTROYER_NAME = "Destroyer";
        
         public const int SHIP_SUBMARINE = 4;
         public const int SHIP_SUBMARINE_AMOUNT = 2;
         public const int SHIP_SUBMARINE_SIZE = 3;
         public SolidColorBrush SHIP_SUBMARINE_COLOR = Brushes.Silver;
         public const String SHIP_SUBMARINE_NAME = "Submarine";

         public const int SHIP_TYPESAMOUNT = 5;
         public const int SHIP_TOTALAMOUNTPERPLAYER = SHIP_CARRIER_AMOUNT + SHIP_BATTLESHIP_AMOUNT + SHIP_CRUISER_AMOUNT + SHIP_DESTROYER_AMOUNT + SHIP_SUBMARINE_AMOUNT;
        

         

         public const int SHIP_STATUS_ALIVE = 0;
         public const int SHIP_STATUS_SUNK = 1;

        
         public const int SQUARE_WATER = 1;
         public const int SQUARE_SHIP = 2;

         public const int GAME_SINGLEPLAYER = 1;
         public const int GAME_MULTIPLAYER = 2;
        
         public const int PLAYER_HUMAN = 1;
         public const int PLAYER_AI = 2;

         public const int PLAYER_NORMAL = 1;
         public const int PLAYER_ADMIN = 2;

         public const int MULTIPLAYER_HOST = 1;
         public const int MULTIPLAYER_CLIENT = 2;

         public const int SIDE_USA = 1;
         public const int SIDE_JAPAN = 2;

         public const int DRAW_COMMANDS_NONE = 0;
         public const int DRAW_COMMANDS_PLACEMENT = 1;
         public const int DRAW_COMMANDS_PLAY = 2;

         public static String TabLettres = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

         public static int SPLASHSCREENTIMER = 3000;

         // SCORES CONSTANTS 
         public int[][] SHIP_SCORES = null;
         public int WATER_PENALTY = -5;

        // END OF SCORE CONSTANTS

        // CONNECTION WINDOW CONSTANTS
         public static int OBJECTIVE_CONNECT = 0;
         public static int OBJECTIVE_EDITPROFILE = 1;

        // END OF CONNECTION WINDOW CONSTANTS


         // WELCOME SCREEN CONSTANTS

         public static String WELCOME_MESSAGE = "      To start a new game, connect first:\nclick on \"Connect...\" in the \"Game\" menu !";
         public static int FOREGROUND = 2;
         public static int BACKGROUND = 1;

         public static int ABSGRID_MAINCELL_ROW = 1;
         public static int ABSGRID_MAINCELL_COLUMN = 0;

         // END OF WELCOME SCREEN CONTENTS

        // RANKS
         public static int RANKS_AMOUNT = 8;

         public String[] RANKS_DESCR_USA = null;
         public String[] RANKS_DESCR_JAP = null;

        // END OF RANKS

        // GENERAL GRID - LEGENDS CONSTANTS

         public static int GENGRID_LGD_TOPROW = 1;
         public static int GENGRID_LGD_BOTTOMROW = 3;
         public static int GENGRID_LGD_LEFT_COLUMN = 0;
         public static int GENGRID_LGD_MIDDLE_COLUMN = 2;
         public static int GENGRID_LGD_RIGHT_COLUMN = 4;

        // END OF GENERAL GRID - LEGENDS CONSTANTS

        // PLACEMENT GRID CONSTANTS

         public static int GRID_PLAC_TITLELINE = 0;
         public static int GRID_PLAC_ITEMSLINE1 = 2;
         public static int GRID_PLAC_ITEMSLINE2 = 4;
         public static int GRID_PLAC_ITEMSLINE3 = 6;
         public static int GRID_PLAC_PLAYBTNLINE = 8;

         public static int GRID_PLAC_BUTTONS_FIRSTCOL = 0;
         public static int GRID_PLAC_VALUES_FIRSTCOL = 1;
         public static int GRID_PLAC_BUTTONS_SECONDCOL = 2;
         public static int GRID_PLAC_VALUES_SECONDCOL = 3;
         public static int GRID_PLAC_BUTTONS_MINESCOL = 4;
         public static int GRID_PLAC_VALUES_MINESCOL = 5;

         public static int GRID_PLAC_PLAYBTN_HORIZSPAN = 6;

         public static double GRID_PLAC_LARGECOLUMNSIZE = 0.23;
         public static double GRID_PLAC_SMALLCOLUMNSIZE = 0.10;
        
         public static double GRID_PLAC_LARGEROW = 0.19;
         public static int GRID_PLAC_SPACEROW_PIX = 3;

         public static String GRID_PLAC_STR_NBLEFT = "# left";
         public static String GRID_PLAC_STR_ZEROVAL = "  0";
         public static String GRID_PLAC_STR_REMOVESHIPS = "Remove ships";
         public static String GRID_PLAC_STR_REMOVEMINES = "Remove mines";
         public static String GRID_PLAC_STR_PLACEMINES = "Place mines";
         public static String GRID_PLAC_STR_MINESTITLE = "Naval mines";
         public static String GRID_PLAC_STR_PLAYBTN = "PLAY !";

         public static  SolidColorBrush GRID_PLAC_WARNINGCOLOR = Brushes.Red;
         public static  SolidColorBrush GRID_PLAC_GOCOLOR = Brushes.Green;
         public static  FontWeight GRID_PLAC_PLAYBTN_FONTWEIGHT = FontWeights.Bold;
         public static SolidColorBrush GRID_PLAC_MINESCOLOR = Brushes.Coral;

         // END OF PLACEMENT GRID CONSTANTS

        // PLAY GRID CONSTANTS

         public static  double GRID_PLAY_COL0_SIZE = 0.40;
         public static  double GRID_PLAY_SPACECOLSIZE = 0.20;
         public static  double GRID_PLAY_COL1_SIZE = 0.08;
         public static  double GRID_PLAY_COL2_SIZE = 0.10;
         public static  double GRID_PLAY_COL3_SIZE = 0.11;
         public static  double GRID_PLAY_COL4_SIZE = 0.11;

         public static  double GRID_PLAY_LARGEROW = 0.19;
         public static  int GRID_PLAY_SPACEROW_PIX = 3;

         public static  String GRID_PLAY_STR_ACTIONSTITLE = "Actions";
         public static  String GRID_PLAY_STR_INFOSTITLE = "Informations";
         public static  String GRID_PLAY_STR_SHIPSSUNKBYYOU = "Ships sunk by you:";
         public static  String GRID_PLAY_STR_SHIPSSUNKBYOPPONENT = "Ships sunk by opponent:";
         public static  String GRID_PLAY_STR_TOURNBR = "Turn number:";
         public static  String GRID_PLAY_STR_YOURSCORE = "Your score:";
         public static  String GRID_PLAY_STR_OPPONENTSCORE = "Opponent's score:";
         public static  String GRID_PLAY_STR_ZEROVAL = "0";

         public static  String GRID_PLAY_STR_FIREBTN = "FIRE!";
         public static  String GRID_PLAY_STR_RADARBTN = "Radar";
         public static  String GRID_PLAY_STR_SABOTAGEBTN = "Sabotage";

         public static String TOOLTIP_PLAYBTN_ENABLED = "Click here to begin the game !";
         public static String TOOLTIP_PLAYBTN_DISABLED = "You cannot begin the game until all your ships and mines are in place !";

         public static  FontWeight GRID_PLAY_FIREBTN_FONTWEIGHT = FontWeights.Bold;
         public static  SolidColorBrush GRID_PLAY_WARNINGCOLOR = Brushes.Red;

         public static  int GRID_PLAY_BUTTONSCOL = 0;
         public static  int GRID_PLAY_SPACECOL = 1;
         public static  int GRID_PLAY_LABELSCOL1 = 2;
         public static  int GRID_PLAY_LABELSCOL2 = 3;
         public static  int GRID_PLAY_LABELSCOL3 = 4;
         public static  int GRID_PLAY_LABELSCOL4 = 5;

         public static  int GRID_PLAY_TITLELINE = 0;
         public static  int GRID_PLAY_LINE1 = 2;
         public static  int GRID_PLAY_LINE2 = 4;
         public static  int GRID_PLAY_LINE3 = 6;
         public static  int GRID_PLAY_LINE4 = 8;

         public const int GAMEMODE_INACTIVE = 0;
         public const int GAMEMODE_ACTIVE_PLACEMENT = 1;
         public const int GAMEMODE_ACTIVE_PLAYFIRE = 2;


        // END OF PLAY GRID CONSTANTS

        //-----------------------------------------------------------------------------------------------------------------------------------------

        public CustomDefines()
        {
            ORIENT_TAB = new ArrayList() { ORIENT_TOBOTTOM, ORIENT_TOLEFT, ORIENT_TOTOP, ORIENT_TORIGHT };

            SHIP_SCORES = new int[][] { new int [] {SHIP_CARRIER, 200}, new int []{SHIP_BATTLESHIP, 175}, new int [] {SHIP_CRUISER, 120},
                                                                            new int [] {SHIP_DESTROYER, 100}, new int[]{SHIP_SUBMARINE, 80}};


            RANKS_DESCR_USA = new String[]  {"Recruit",     "Seaman",       "Chief officer",    "Master chief officer",      
                                                "Lieutenant",   "Commander",    "Vice-admiral",     "Admiral"};

            RANKS_DESCR_JAP = new String[]  {"Nitōsuihei",  "Ittōsuihei",   "Ittōheisō",        "Jōtōheisō",
                                                "Kaigun Daii",  "Kaigun Chūsa",    "Kaigun Chūjō",  "Kaigun Taishō"};

        }


        //-----------------------------------------------------------------------------------------------------------------------------------------
        // STRUCTURES ALLOWING COMMUNICATION WITH THE AI
        //-----------------------------------------------------------------------------------------------------------------------------------------
        public struct PlacedShip_Struct
	    {
		    public int Type;
            public int Life;
            public int Size;
            public int X;
            public int Y;
            public int Orient;
	    }

        public struct Coord_Struct
        {
            public int X;
		    public int Y;
        }

        public struct ShotStatus_Struct
	    {
		    public int Status; // RANDOM ou TARGETTING
		    public int Orient;
		    public int End;
		    public Coord_Struct ShipEnd;
		    public Coord_Struct LastHit;
		    public Coord_Struct FirstHit;
		    public bool SideChanged;
	    } 

        //-----------------------------------------------------------------------------------------------------------------------------------------
        // END OF AI COMMUNICATION STRUCTURES 
        //-----------------------------------------------------------------------------------------------------------------------------------------      


    }
}
